import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDPetLv {
	/**等级*/
	id,
	/**消耗道具1--消耗道具id：global[9]*/
	costINum1,
	/**消耗道具2消耗道具id：global[10]*/
	costINum2,
	/**消耗道具3消耗道具id：global[11]*/
	costINum3,
	/**返回道具1消耗道具id：global[9]*/
	backNum1,
	/**返回道具2消耗道具id：global[10]*/
	backNum2,
	/**返回道具3消耗道具id：global[11]*/
	backNum3,
	/**角色等级限制*/
	reqPlayerLv,

	/**枚举数量*/
	EnumCount
}



export class CDPetLv{
	/**等级*/
	public id: number;
	/**消耗道具1--消耗道具id：global[9]*/
	public costINum1: number;
	/**消耗道具2消耗道具id：global[10]*/
	public costINum2: number;
	/**消耗道具3消耗道具id：global[11]*/
	public costINum3: number;
	/**返回道具1消耗道具id：global[9]*/
	public backNum1: number;
	/**返回道具2消耗道具id：global[10]*/
	public backNum2: number;
	/**返回道具3消耗道具id：global[11]*/
	public backNum3: number;
	/**角色等级限制*/
	public reqPlayerLv: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDPetLv.id: return this.id;
			case E_CDPetLv.costINum1: return this.costINum1;
			case E_CDPetLv.costINum2: return this.costINum2;
			case E_CDPetLv.costINum3: return this.costINum3;
			case E_CDPetLv.backNum1: return this.backNum1;
			case E_CDPetLv.backNum2: return this.backNum2;
			case E_CDPetLv.backNum3: return this.backNum3;
			case E_CDPetLv.reqPlayerLv: return this.reqPlayerLv;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDPetLv.id: this.id = v; break;
			case E_CDPetLv.costINum1: this.costINum1 = v; break;
			case E_CDPetLv.costINum2: this.costINum2 = v; break;
			case E_CDPetLv.costINum3: this.costINum3 = v; break;
			case E_CDPetLv.backNum1: this.backNum1 = v; break;
			case E_CDPetLv.backNum2: this.backNum2 = v; break;
			case E_CDPetLv.backNum3: this.backNum3 = v; break;
			case E_CDPetLv.reqPlayerLv: this.reqPlayerLv = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDPetLv> = new HashMap<number, CDPetLv>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDPetLv[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDPetLv();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].costINum1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costINum2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costINum3 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backNum1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backNum2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].backNum3 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].reqPlayerLv = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDPetLv{
		return this.datas ? this.datas.get(id) : null;
	}
}
